<template>
  <div class="commodity-history">
    <a-drawer
      title="订单详情"
      :width="drawerWidth"
      :visible="isShowDrawer"
      @close="onClose"
    >
    <div class="order-container">
      <div class="order-top">
        <img src="../../../../assets/image/sellerHub/order_num.png" alt="">
        <span>订单编号：{{drawerData.subOrderNo}}</span>
        <img style="cursor: pointer;" src="../../../../assets/image/sellerHub/copy.png" alt="copy" @click="copyOrderId">
        <input id="copyOrderId" style="position: absolute;top: 0;left: 0;opacity: 0;z-index: -10" v-model="drawerData.orderId"/>
        <span class="dangban"></span>
        <span>订单日期：{{$dateTrans(drawerData.orderTime).format('yyyy-MM-dd hh:mm:ss')}}</span>
        <span class="order-top-right">
          <img v-if="drawerData.subStatus==6" src="../../../../assets/image/sellerHub/transaction.png" alt="">
          <img v-if="drawerData.subStatus==8" src="../../../../assets/image/sellerHub/cancelstate.png" alt="">
          <img v-if="drawerData.subStatus==2||drawerData.subStatus==3||drawerData.subStatus==4||drawerData.subStatus==5" src="../../../../assets/image/sellerHub/payState.png" alt="">
          <span v-if="drawerData.subStatus==6">已完成</span>
          <span v-if="drawerData.subStatus==8" style="color: #272424;">已取消</span>
          <span v-if="drawerData.subStatus==2||drawerData.subStatus==3||drawerData.subStatus==4||drawerData.subStatus==5">已付款</span>
        </span>
      </div>
      <div class="order-card-bg">
        <ul><li></li><li></li><li></li><li></li></ul>
      </div>
      <div class="order-card">
        <ul>
          <li>
            <p><i></i>收货人信息</p>
            <p>联系人：<span>{{drawerData.receiveName}}</span></p>
            <p>联系电话：<span>{{drawerData.receiveMobile}}</span></p>
            <p>地址信息：<span>{{drawerData.receiveFullAddress}}</span></p>
          </li>
          <li>
            <p><i></i>配送方式</p>
            <p>配送方式：<span class="item-log">{{drawerData.deliveryType==1 ? '2S自提' : drawerData.deliveryType==2 ? '平台配送':drawerData.deliveryType==3 ? '半日达': '极速达'}}</span></p>
            <p v-for="(item ,i) in (drawerData.logistics||[])" :key="i">承运方：<span>{{item.carrierName}}</span></p>
          </li>
          <li>
            <p><i></i>付款信息</p>
            <p>实付金额：<span>￥{{drawerData.realPaid}}</span></p>
            <p>付款金额：<span v-if="drawerData.payType&&true">{{drawerData.payType==1 ? '微信支付' : drawerData.payType==2 ? '支付宝支付':'银联支付'}}</span></p>
            <p>付款时间：<span>{{ detailData.payTime ? $dateTrans(detailData.payTime).format('yyyy-MM-dd hh:mm:ss') : ''}}</span></p>
            <p>支付流水单号：<span>{{drawerData.subSerialNo}}</span></p>
          </li>
          <li>
            <p><i></i>买家信息</p>
            <p>买家：<span>{{drawerData.tenantName}}</span></p>
            <p>买家留言：<span>{{detailData.comment}}</span></p>
          </li>
        </ul>
      </div>
    </div>
    <div class="dividing-line"></div>
    <div class="order-card-goods">
    <a-row type="flex" class="table-title" style="color: #272424;">
        <a-col :span="6" class="textOverflow" style="text-align:left;padding-left:12px;">
          商品
        </a-col>
        <a-col :span="3" class="textOverflow">
          单价(元)
        </a-col>
        <a-col :span="3" class="textOverflow">
          金额(元)/数量
        </a-col>
        <a-col :span="5" class="textOverflow">
          配货信息
        </a-col>
        <a-col :span="5" class="textOverflow">
          售后信息
        </a-col>
        <a-col :span="2" class="textOverflow">
          商品状态
        </a-col>
      </a-row>
      <div class="table-items" style="color: #272424;" v-for="(item, i) in distributionInfoList" :key="i">
        <div class="item-container">
          <a-row type="flex">
            <a-col :span="12">
              <a-row type="flex" class="item-container-left"  v-for="(_item,index) in (item.distributionInfoMaterialList||[])" :key="index+i"  align="middle">
                <a-col :span="12" class="textOverflow">
                  <div class="order-table-name" style="text-align:left;">
                    <img class="dinghuo" src="../../../../assets/image/sellerHub/dinghuo.png" alt="">
                    <img :src="_item.materialImg" alt="">
                    <div class="table-name-right" style="width: calc(100% - 60px);">
                      <div class="right-item textOverflow">
                        <span>{{_item.materialName}}</span>
                        <em>|</em>
                        <i class="textOverflow" >零件号:{{_item.manufacturerPartNum}}</i>
                      </div>
                      <div class="right-item textOverflow">
                        <span class="item-label">规格：</span>
                        <span>{{_item.specifications}}</span>
                      </div>
                    </div>
                  </div>
                </a-col>
                <a-col :span="6" class="textOverflow">
                  {{_item.price}}
                </a-col>
                <a-col :span="6" class="textOverflow" style="text-align:right;">
                  <p style="margin-right:13px;">{{_item.totalMoney}}</p>
                  <p style="margin-right:13px;">{{_item.quantity}}{{_item.unit}}</p>
                </a-col>
              </a-row>
            </a-col>
            <a-col :span="5" class="textOverflow border-right">
              <div class="vertical-middle">
                <p>配货单号：{{item.distributionNo}}</p>
                <p v-if="item.state==0" class="distribution-status distribution-status-yellow">待配货</p>
                <p v-if="item.state==1" class="distribution-status distribution-status-green">已配货</p>
                <p v-if="item.state==2" class="distribution-status distribution-status-yellow">待提货</p>
                <p v-if="item.state==3" class="distribution-status distribution-status-green">已提货</p>
                <p v-if="item.state==4" class="distribution-status distribution-status-green">已收货</p>
              </div>
            </a-col>
            <a-col :span="5" class="textOverflow border-right">
              <div class="vertical-middle">
                --
              </div>
            </a-col>
            <a-col :span="2" class="textOverflow border-right">
              <div class="vertical-middle">
                <p v-if="item.materialState==1" class="distribution-status distribution-status-yellow">待发货</p>
                <p v-if="item.materialState==2" class="distribution-status distribution-status-green">已发货</p>
                <p v-if="item.materialState==3" class="distribution-status distribution-status-green">已收货</p>
                <p v-if="item.materialState==4" class="distribution-status distribution-status-grey">已取消</p>
              </div>
            </a-col>
          </a-row>
        </div>
      </div>
      <p></p>
    
    
    
    
    
   
    </div>
    <p class="order-price">商品总价(元):<span>￥{{drawerData.subMoney}}</span></p>
    <br/>
    <p class="order-price">实收金额(元):<span>￥{{drawerData.realPaid}}</span></p>
    <div class="none"></div>
    <div class="cancel-order">
      <div class="cancel-btn">取消订单</div>
    </div>
    </a-drawer>
  </div>
</template>
<script>
import Vue from 'vue'
import {Drawer} from 'ant-design-vue'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
Vue.use(Drawer)
//历史价格table配置

export default {
  model: {
    prop: 'isShowDrawer',
    event: 'change'
  },
  props: {
    isShowDrawer: Boolean,
    drawerData: Object,
  },
  components:{},
  data() {
    return {
      drawerWidth: window.innerWidth*0.8,
      locale: zhCN,
      detailData: {},
      distributionInfoList: [],
    }
  },
  computed: {
    stockHistory() {
      
    },
  },
  watch: {
    isShowDrawer() {
      this.init();
    }
  },
  created() {
    
  },
  methods: {
    init() {
      this.detailData = {}
      this.distributionInfoList = []
      if(!this.drawerData.id){
        return
      }
      this.$store.dispatch('request', this.$api.sellerCenter.getFourServiceOrderDetail(this.drawerData.id)
      ).then(res => {
        let result = res.result || {}
        this.detailData = result
        this.distributionInfoList = result.distributionInfoList || []
      }).catch(() => {
      })
    },
    copyOrderId(){
      if(this.drawerData.orderId){
        let copyInput = document.getElementById('copyOrderId')
        copyInput.select(); // 选中文本
        document.execCommand("copy"); // 执行浏览器复制命令

        console.log(copyInput)
        this.$message.success('复制成功');
      }
    },
    onClose() {
      this.$emit('change',false)
    },
  },
}
</script>
<style lang="less">
.ant-drawer-body {
  padding: 0;
}
.bottom-pagination-card>.paginationBefore {
    float: right;
    line-height: 70px;
    i {
      color: @activeRed;
    }
  }
.bottom-pagination-card {
  position: fixed;
  bottom: 0;
  width: 80%;
  background: #fff;
  right: 0;
  box-shadow: 0px -2px 2px 0px rgba(39,36,36,0.02); 
  padding-right: 30px;
}
.order-container {
  padding: 12px;
  position: relative;
  .order-top {
    background: url('../../../../assets/image/sellerHub/order_bg.png') no-repeat center top;
    background-size: 100% 100%;
    width: 100%;
    height: 112px;
    position: relative;
    z-index: 2;
    background-clip: content-box;
    padding-bottom: 7px;
    line-height: 80px;
    span {
      vertical-align: middle;
    }
    img:nth-of-type(1) {
      width: 24px;
      margin-left: 24px;
      margin-right: 8px;
    }
    img:nth-of-type(2) {
      width: 16px;
      margin: 0 16px 0 8px;
    }
    .order-top-right {
      float: right;
      margin-right: 64px;
      font-size: 20px;
      font-weight: 600;
      color: #79c860;
      img {
        width: 50px;
      }
    }
    .dangban {
      margin-right: 16px;
      height: 12px;
      display: inline-block;
      width: 1px;
      background: #ebedf2;
    }
  }
  .order-card-bg,.order-card {
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    font-size: 12px;
    ul>li {
      float: left;
      width: 23.8%;
      min-height: 172px;
      margin:0 16px 16px 0;
    }
    ul>li:last-child {
      margin-right: 0;
    }
  }
  .order-card-bg {
    width: calc(100% - 11px);
    box-shadow: 0px 0px 6px 1px rgba(39,36,36,0.06); 
    margin-top: -8px;
    ul {
      overflow: hidden;
    }
  }
  .order-card {
    position: absolute;
    padding: 0 24px;
    z-index: 3;
    top: 108px;
    left: 18px;
    width: calc(100% - 36px);
    ul>li {
      padding: 16px;
      background: #fafafa;
      p {
        margin-bottom: 7px;
        position: relative;
        color: rgba(39,36,36,0.60);
        span {
          position: absolute;
          color: #272424;
          display: inline-block;
          left: 60px;
          word-break: break-all;
        }
      }
      p:nth-of-type(1) {
        margin-bottom: 16px;
        font-weight: 600;
        position: relative;
        i {
          width: 4px;
          height: 12px;
          background: @activeRed;
          position: absolute;
          left: -16px;
          top: 5px;
        }
      }
      .item-log {
        display: inline-block;
        background: rgba(215,55,55,0.08);
        border-radius: 8px 0px 8px 0px;
        height: 26px;
        line-height: 26px;
        padding: 0 8px;
        color: @activeRed; 
      }
    }
    ul>li:nth-of-type(3) {
      p>span {
        left: 86px;
      }
      p:nth-of-type(2) {
        span {
          font-size: 14px;
          color: @activeRed;
        }
      }
    }
  }
  .cashierNav {
    width: calc(100% - 12px);
    border-bottom: 1px solid rgba(39,36,36,0.08);
    overflow: hidden;
    margin-left: 6px;
    margin-top: 8px;
    li {
      float: left;
      margin-right: 40px;
      line-height: 52px;
      height: 52px;
      cursor: pointer;
    }
    .li-checked {
      color: @activeRed;;
      border-bottom: 3px solid @activeRed;
    }
    li:hover {
      color: @activeRed;;
      border-bottom: 3px solid @activeRed;
    }
  }
  .order-nav-list {
    width: calc(100% - 12px);
    border: 1px solid rgba(39,36,36,0.08);
    height: 137px;
    margin-top: 16px;
    margin-left: 6px;
    .nav-list-msg {
      padding: 24px;
      width: 372px;
      height: 100%;
      float: left;
      border-right: 1px solid rgba(39,36,36,0.08);
      p {
        margin-bottom: 9px;
      }
      img {
        width: 16px;
      }
      img:last-child {
        margin-left: 8px;
      }
      span {
        display: inline-block;
        vertical-align: middle;
        color: #272424;
      }
      span:nth-of-type(1) {
        display: inline-block;
        width: 70px;
        color: rgba(39,36,36,0.60);
        margin-left: 8px;
      }
    }
    .nav-list-goods {
      width: calc(100% - 372px;);
      overflow: hidden;
      float: left;
      height: 137px;
      position: relative;
      .next {
        height: 100%;
        position: absolute;
        right: 0;
        width: 24px;
        top: 0;
        z-index: 8;
        cursor: pointer;
        line-height: 137px;
        text-align: center;
        background: #fff;
        box-shadow: -4px 0px 6px 0px rgba(0,0,0,0.04); 
      }
      .previous {
        left: 0;
        box-shadow: 4px 0px 6px 0px rgba(0,0,0,0.04);
      }
    }
    .nav-goods {
      height: 137px;
      position: absolute;
      left: 0;
      li {
        white-space:nowrap;
        display: inline-block;
        width: 146px;
        height: 137px;
        padding: 24px;
        margin-right: 16px;
        img {
          width: 60px;
          height: 60px;
          border-radius: 2px;
          margin-bottom: 8px;
          box-shadow: 0px 0px 6px 0px rgba(39,36,36,0.04); 
        }
        p {
          span {
            height: 16px;
            display: inline-block;
            line-height: 16px;
          }
          span:first-child {
            background: #fff;
            border-radius: 0 0 8px 0;
            padding: 0 16px 0 0;
            position: relative;
            z-index: 2;
            color: #272424;
          }
          span:last-child {
            background: rgba(215,55,55,0.08);
            border-radius: 2px 2px 2px 0px;
            color: @activeRed;
            padding: 0 6px 0 12px;
            margin-left: -6px;
            font-size: 12px;
          }
        }
      }
    }
  }
}
.dividing-line {
  width: 100%;
  height: 16px;
  background: #f8f8f8;
  margin: 24px 0 0;
}
.order-card-goods {
  padding: 8px 24px;
}
.order-price {
  width: 210px;
  float: right;
  margin-right: 24px;
  margin-top: -8px;
  span {
    float: right;
  }
}
.order-price:nth-of-type(1) {
  font-size: 12px;
  color: rgba(39,36,36,0.6);
}
.order-price:nth-of-type(2) {
  color: rgba(39,36,36,1);
  line-height: 27px;
  margin-bottom: 16px;
  span {
    font-size: 18px;
    color: @activeRed;
  }
}
.item-container {
  min-height: 92px;
  padding: 16px 0;
  margin-bottom: 16px;
  border: 1px solid rgba(39,36,36,0.08);
  border-radius: 0 0 2px 2px;
  font-size: 12px;
  .msg-left {
    padding-left: 12px;
    color: rgba(39,36,36,1);
    width: calc(100% - 145px);
    p {
      overflow: hidden;
      margin-bottom: 6px;
    }
    span:first-child {
      display: inline-block;
      color: rgba(39,36,36,0.6);
      position: absolute;
      left: 12px;
    }
    span:last-child {
      margin-left: 72px;
      display: inline-block;
    }
    P:first-child {
      span:last-child {
        color: @activeRed;
      }
    }
  }
  .msg-right {
    position: absolute;
    right: 16px;
    width: 130px;
    top: 0px;
    overflow-y: scroll;
    height: 100%;
    img {
      width: 60px;
      height: 60px;
      margin-bottom: 10px;
    }
    img:nth-child(odd) {
      margin-right: 10px;
    }
  }
  .msg-right::-webkit-scrollbar {
    display: none;
  }
}
.none {
  height: 100px;
  width: 100%;
}
.cancel-order {
  position: fixed;
  width: 80%;
  background: #fff;
  bottom: 0;
  right: 0;
  height: 56px;
  box-shadow: 0px -2px 2px 0px rgba(39,36,36,0.02); 
  .cancel-btn {
    width: 128px;
    height: 56px;
    float: right;
    text-align: center;
    background: #f8f8f8;
    color: #272424;
    line-height: 56px;
    cursor: pointer;
  }

}
</style>